package com.example.btchat.server;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

import android.bluetooth.BluetoothSocket;

public class Connection
{
	public OutputStream output = null;
	public InputStream input = null;
	public BluetoothSocket socket = null;
	
	public Connection(BluetoothSocket socket) throws IOException
	{
		try
		{
			this.socket = socket;
			this.input = socket.getInputStream();
			this.output = socket.getOutputStream();
		}
		catch(IOException e)
		{
			this.close();
			throw e;
		}
	}
	
	public void close()
	{
		try
		{
			this.input.close();
		}
		catch(Exception e)
		{}
		
		try
		{
			this.output.close();
		}
		catch(Exception e)
		{}
		
		try
		{
			this.socket.close();
		}
		catch(Exception e)
		{}
	}
}
